﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.IO;

namespace VPLink2013.Framework.Extensions
{
    public static partial class FrameworkExtensions
    {
        public static int? ToInt32(this double? input)
        {
            try
            {
                if (input == null)
                {
                    return null;
                }

                var inputValue = input.Value;
                double value = System.Math.Round(inputValue);

                int convertedValue = System.Convert.ToInt32(value);
                return convertedValue;

            }
            catch (Exception ex)
            {
                //TODO : log
                string msg = ex.Message;
                return null;
            }
        }
    }
}
